import axios from 'axios';
import qs from 'qs';
var $v = new function() {
	this.ezajax = function(url, data, sucfun, errorfuc, method, headers) {
		headers = headers == undefined ? {} : headers;
		headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
		var res = axios({
			url: url,
			data: data == undefined ? {} : qs.stringify(data),
			headers: headers,
			method: "get" == method ? "get" : "post",
			withCredentials: true
		}).then(function(result) {
			if (sucfun != null) sucfun(result.data);
		}).catch(function(reason) {
			console.log(reason);
			if (errorfuc != null) errorfuc(reason);
		});

		//axios.post(url, data);
	};

	this.test = function() {
		alert("test");
	};
	return this;
};

export default $v
// module.exports=$v
